<template>
	<view style="padding: 30rpx;">
		<view style="margin-top: 0rpx;" v-for="(item,index) in yyList" :key="index">
			<view style="display: block;"  >
				<view style="width: 100%;display: flex;" @click="goinfo(item)">
					<view style="width: 550rpx;">
						<text class="hide"
							style="font-weight: 500;font-size: 32rpx;color: color: rgba(0, 0, 0, 0.6);">{{item.name}}</text>
					</view>
					<view style="flex: 1;float: right;margin-right: 1rpx;">
						<view style="float: right;margin-right: 1rpx;">
							<text style="font-weight: 500;color:#EA5344;font-size: 32rpx;">{{item.cprice}}</text>
							<text style="font-weight: 500;color: #EA5344;font-size: 28rpx;">元</text>
							<text style="color: rgba(42, 42, 42, 0.7) ;">起</text>
						</view>
						
						
					</view>
				</view>
				<view style="width: 100%;display: flex;" @click="goinfo(item)">
					<view style="width: 550rpx;">
						<text class="hide"
						
							style="margin-top: 15rpx; font-weight: 400;font-size: 28rpx;color: rgba(42, 42, 42, 0.7);">{{item.address}}</text>
						
					</view>
					<view style="flex: 1;">
						<text v-if="item.distance < 1000"
							style="float: right;margin-right: 1rpx;font-size: 28rpx; color: rgba(42, 42, 42, 0.7);font-weight: 400;margin-top: 15rpx; ">{{item.distance}}m</text>
						<text v-else
							style="float: right;margin-right: 1rpx;font-size: 28rpx;color: rgba(42, 42, 42, 0.7);font-weight: 400;margin-top: 15rpx; ">{{(item.distance/1000).toFixed(1)}}km</text>
					</view>
				</view>
			</view>
			<u-line color="#d5d5d5" margin="15rpx 0rpx" />
		</view>
		
		
		<view v-if="yyList.length >0">
			<u-loadmore :status="status" />
		</view>
		<view v-if="shownull" style="margin-top: 30rpx;">
			<u-empty icon-size="160" margin-top="200" font-size="30"  text="暂无排片信息" src="/static/images/yy.png"></u-empty>
		</view>
		<aui-loading ref="auiLoading" :type="auiLoading.type" :direction="auiLoading.row" :msg="auiLoading.msg"
			:mask="auiLoading.mask"></aui-loading>
	</view>
</template>

<script>
	import Config from '../../common/config.js'
	import {
		aui
	} from '@/components/aui-loading/common/aui/js/aui.js';
	import auiLoading from '@/components/aui-loading/aui-loading.vue';
	import {
		myRequest,
		
	} from '../../common/api.js'
	export default {
		components: {
			auiLoading
		},
		data() {
			return {
				shownull:false,
				auiLoading: {
					shownull:false,
					show: false,
					type: 3,
					direction: 'row',
					msg: '加载中',
					mask: true,
				
				},
				status: 'loadmore',
				page: 1,
				isshow: false,
				current: 0,
				yyList: [],
				yyList1: [],
				tablist: [],
				name: "影片",
				filmId: 0,
				allpage:0,
				location: {
					name: "暂无位置",
					cityId: "1"
				},
				latitude: 0,
				longitude: 0,

			}
		},
		onLoad(pamar) {
			this.location = Config.loaction;
			this.longitude = Config.lon;
			this.latitude = Config.lat;
			this.name = pamar.name;
			this.filmId = pamar.filmId;
			uni.setNavigationBarTitle({
				title: this.name
			})
			this.initdata()
		},
		onPullDownRefresh() {
			this.yyList=[]
			this.getyy(this.current)
		},
		onReachBottom() {
			if (this.page >= this.allpage) {
				this.status = 'nomore';
				return;
			}
			this.status = 'loading';
			this.page = ++this.page;
			this.getyy(this.current)
			this.status = 'loadmore';
			
		},
		methods: {
			pageTotal(rowCount, pageSize) {
				if (rowCount == null || rowCount == "") {
					return 0;
				} else {
					if (pageSize != 0 && rowCount % pageSize == 0) {
						return parseInt(rowCount / pageSize)
					}
					if (pageSize != 0 && rowCount % pageSize != 0) {
						return parseInt(rowCount / pageSize) + 1;
					}
				}
			},
			gosearch(){
				uni.navigateTo({
					url:'../search/search'
				})
			},
			goinfo(item) {
				
				uni.navigateTo({
					url: '../cinemainfo/cinemainfo?Id=' + item.id + '&name=' + item.name + '&address=' + item
						.address + '&coord=' + item.coord + '&filmId=' + this.filmId
				});
			},
			addDate(date, days) {
				var d = new Date(date);
				d.setDate(d.getDate() + days);
				return d;
			},
			initdata() {
				var myDate = new Date();
				var weekName = new Array("周日", "周一", "周二", "周三", "周四", "周五", "周六");
				let todayText = "今天" + (myDate.getMonth() + 1) + "月" + myDate.getDate() + "日";
				let a = {
					name: todayText,
					key: myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate() + " 00:00:00"
				}

				this.tablist.push(a)
				let tmpdata = this.addDate(myDate, 1)

				let tomorrowText = "明天" + (tmpdata.getMonth() + 1) + "月" + tmpdata.getDate() + "日";
				a = {
					name: tomorrowText,
					key: tmpdata.getFullYear() + "-" + (tmpdata.getMonth() + 1) + "-" + tmpdata.getDate() + " 00:00:00"
				}
				this.tablist.push(a)
				tmpdata = this.addDate(myDate, 2);
				let htText = "后天" + (tmpdata.getMonth() + 1) + "月" + tmpdata.getDate() + "日";
				a = {
					name: htText,
					key: tmpdata.getFullYear() + "-" + (tmpdata.getMonth() + 1) + "-" + tmpdata.getDate() + " 00:00:00"
				}
				this.tablist.push(a)
				this.getyy(0)

			},
			change(index) {
				this.current = index;
				
				this.getyy(index)
			},
			getljtime(cinemaId) {
				var that = this;
				let seltime = that.tablist[that.current].key;
				return new Promise((resolve, reject) => {
					uni.request({
						url: Config.ServerIP + "/movie/app/movie/filmShowCinema/session/list",
						method: "POST",
						data: {
							cinemaId: cinemaId,
							cityId: Config.loaction.cityId,
							direction: "desc",
							filmId: that.filmId,
							pageNum: that.page,
							pageSize: 20,
							showTime: seltime
						},
						success: (res) => {
							
							resolve(res)

						},
						fail: function(e) {
							
							reject(e)
						},

					})
				})




			},

			getyy(index) {
				let seltime = this.tablist[index].key;
				
				let that = this;
				that.$refs.auiLoading.show();
				myRequest({
					url:'/movie/app/movie/filmShowCinema/film/city/list',
					methods: "POST",
					data: {
						cityId: Config.loaction.cityId,
						direction: "asc",
						orderBy:'distance',
						filmId: that.filmId,
						latitude: Config.lat,
						longitude: Config.lon,
						pageNum: that.page,
						pageSize: 20,
						showTime: seltime
					}
				}).then(res => {
					let c = that.yyList
					that.yyList =c.concat(res.data.data) 
					that.allpage = that.pageTotal(res.data.total, 20);
					that.$refs.auiLoading.hide();
					that.isshow = true
					
					if(that.yyList.length <=0){
						that.shownull = true
					}else{
						that.shownull =false
					}
					uni.stopPullDownRefresh()
				});
			}

		}
	}
</script>

<style>
.hide {
		display: -webkit-box;
		/*设置为弹性盒子*/
		-webkit-line-clamp: 1;
		/*最多显示1行*/
		overflow: hidden;
		/*超出隐藏*/
		text-overflow: ellipsis;
		/*超出显示为省略号*/
		-webkit-box-orient: vertical;
		/* 从上向下垂直排列子元素。 */

	}
</style>
